<?php

namespace App\Models\Biz;

use Illuminate\Database\Eloquent\Model;

class Track extends Model
{
    protected $table = 'biz_tracks';

    protected $guarded = array();

    public $timestamps = false;

    //积分奖励类型
    const TRACK_TYPE_READER = 1;      //签到积分

    const TRACK_TYPE_VOLUNTEER = 2; //志愿者积分

    const TRACK_TYPE_AWARD = 3;     //奖励积分

    const TRACK_TYPE_EXTRA = 4;     //活动积分

    public function user()
    {
        return $this->hasOne('App\Models\Mgt\User', 'id', 'uid');
    }


    public function activity()
    {
        return $this->belongsTo('App\Models\Mgt\Activity', 'aid', 'id');
    }

    public function scopeReader($query)
    {
        return $query->where('type', self::TRACK_TYPE_READER);
    }

    public function scopeVolunteer($query)
    {
        return $query->where('type', self::TRACK_TYPE_VOLUNTEER);
    }
    /*
    public static function setRecord($aid, $uid, $account, $type)
    {
        $record = new \App\Models\BizRecord;

        $record->aid = $aid;
        $record->uid = $uid;
        $record->account = $account;
        $record->type = $type;
        $record->date = time();
        
        $record->save();

    }*/


}